<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #toolbar {
            position: -webkit-sticky;
            /* safari 浏览器 */
            position: sticky;
            /* 其他浏览器 */
            top: 200px;
            background-color: saddlebrown;
            height: 20px;
        }

        .parent {
            height: 500px;
            background-color: gray;
            overflow-y: scroll;
        }
    </style>
</head>

<body>
    <div class="parent">
        <div id="toolbar"></div>
        <div style="height: 1200px;background-color: green;"></div>

    </div>
</body>

</html>